<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>『ThinkPHP管理平台』By ThinkPHP 3.1.3</title>
    <link rel="stylesheet" type="text/css" href="{{asset('admin_style/css/blue.css')}}" />
    <link rel="stylesheet" href="{{ asset('admin_style/css/pintuer.css') }}">
    <link rel="stylesheet" href="{{ asset('admin_style/css/admin.css') }}">
    <script src="{{asset('admin_style/js/jquery.js')}}"></script>
    <script src="{{asset('admin_style/js/pintuer.js')}}"></script>
    <link rel="stylesheet" href="{{asset('admin_style/css/style.css')}}">
    <script src="{{asset('admin_style/js/layer/layer.js')}}"></script>
</head>
<body>
<!-- 主页面开始 -->
<div id="box" class="main" >
    <!-- 主体内容  -->
    <div class="content" >
        <div class="title"> 权限设置 </div>
        <div id="result" class="result none"></div>
        <table class="select" style="width:265px" align="center">
            <tr><td height="3" colspan="3" class="topTd" ></td></tr>
            <tr>
                <th class="tCenter">当前组：{{$row->r_name}}
                </th>
            </tr>
            <tr><Td class="tRight">请选择：
                    <select style="width: 192px" id="select_id">
                        <option value=" ">请选择:</option>
                        @foreach($data1 as $v)
                            <option value="{{$v->id}}" onclick="middle({{$id}},{{$v->id}})">{{$v->n_name}}</option>
                        @endforeach
                    </select>
                </Td></tr>
            <tr>
                <td height="50">
                <div id="box2">

                </div>
                </td>
            </tr>
            <tr>
                <td  class="row tCenter">
                    <input type="hidden" id="aid" value="{{$row->r_id}}">
                    <input class="button" type="submit" value="确定" onclick="submit()">
                </td>
            </tr>
            <tr>
                <td height="4" class="bottomTd" >
                </td>
            </tr>
        </table>
    </div>
</div>
</body>
</html>
<script>
    function submit() {
        var rid = document.getElementById('aid').value;
        var selected_val = document.getElementById('select_id').value;
        var check = document.getElementsByName('check');
        var str = " ";
        var ids=[];
        for(var i=0;i<check.length;i++){
            if(check[i].checked){
                ids.push(check[i].value);
            }
        }
        var str = ids.join(',');
        if(selected_val == " "){
            alert("请先选择一个模块");
        }else{
            var xh      = new XMLHttpRequest();
            xh.open('get',"{{url('node/module/')}}/"+rid+'/'+str+'/'+selected_val,true);
            xh.send();
            xh.onreadystatechange = function(){
                if(xh.readyState == 4 && xh.status==200){
                    document.getElementById('box').innerHTML=xh.responseText;
                }
            }
        }
    }
    function middle($id,$node_id){
        var xh      = new XMLHttpRequest();
        xh.open('get',"{{url('node/middle/')}}/"+$id+'/'+$node_id,true);
        xh.send();
        xh.onreadystatechange = function(){
            if(xh.readyState == 4 && xh.status==200){
                document.getElementById('box2').innerHTML=xh.responseText;
            }
        }
    }
</script>